<template>
  <div class="box-list-container">
    <!-- <div class="box-query-form">
      <el-form :model="queryParam" label-width="auto" label-position="right" :gutter="24">
        <el-row>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="分类名:">
              <el-input v-model="queryParam.classs" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="评语:">
              <el-input v-model="queryParam.remark" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col v-if="userInfo.userType === '666'" :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="所属用户:">
              <selectUser v-model.trim="queryParam.UserNum" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24" class="table-search-btn">
            <el-button icon="el-icon-refresh" @click="searchReset">重置</el-button>
            <el-button type="primary" icon="el-icon-search" @click="searchQuery">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div> -->
    <div class="box-table">
      <div class="table-title">
        <div class="table-title-left">
          评价统计列表
        </div>
        <div>
          <el-button type="primary" icon="el-icon-refresh" @click="getList">刷新</el-button>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd('新增')">新增</el-button>
          <!-- <el-button type="success" icon="el-icon-download" :loading="exportTxtLoading" @click="exportTxt">导出txt</el-button> -->
        </div>
      </div>
      <el-table ref="table" :data="dataSource">
        <!-- <el-table-column v-if="userInfo.userType === '666'" label="所属用户" prop="UserNum" min-width="100" /> -->
        <el-table-column prop="classs" label="分类" min-width="200" />
        <el-table-column prop="rCount" label="统计" min-width="200" />
        <el-table-column fixed="right" label="操作" width="100">
          <template slot-scope="scope">
            <el-button type="text" @click="handleShowRemark('评语列表', scope.row)">明细</el-button>
            <!-- <el-button type="text" @click="handleEdit('编辑', scope.row)">编辑</el-button>
            <el-popconfirm title="确定删除吗？" style="margin-left: 10px" @confirm="handleDelete(scope.row[guidFieldName])">
              <el-button slot="reference" type="text" style="color: red;">删除</el-button>
            </el-popconfirm> -->
          </template>
        </el-table-column>
      </el-table>
    </div>
    <handleDrawer ref="modalForm" @ok="modalFormOk" />
    <remarkModel ref="remarkModel" @ok="modalFormOk" />
  </div>
</template>

<script>
import remarkModel from './components/remarkModel'
import handleDrawer from './components/handleDrawer'
// import selectUser from '@/components/xm/selectUser/selectUser'
import { listMixin } from '@/mixins/listMixin'
import { txtDown } from '@/utils'
import { postAction } from '@/api/manage'

export default {
  components: {
    remarkModel,
    handleDrawer
  },
  mixins: [listMixin],
  data() {
    return {
      guidFieldName: 'id',
      dataSource: [],
      queryParam: {},
      exportTxtLoading: false,
      disableMixinCreated: true,
      userInfo: this.$ls.get('USER_INFO') || {},
      url: {
        list: 'evaluateList.aspx?action=GetClassStatisList'
      }
    }
  },
  created() {},
  mounted() {
    this.getList()
  },
  methods: {
    getList() {
      this.$store.dispatch('app/setLoading', true)
      postAction('evaluateList.aspx?action=GetClassStatisList', this.model).then((res) => {
        if (res.code === 1) {
          this.dataSource = res.data
          this.$message.success(res.message || '操作成功！')
        } else {
          this.$message.warning(res.message || '操作失败！')
        }
      }).finally(() => {
        this.$store.dispatch('app/setLoading', false)
      })
    },
    modalFormOk() {
      this.getList()
    },
    // 显示分类旗下评语
    handleShowRemark(title, rowData) {
      this.$refs.remarkModel.show(rowData)
      this.$refs.remarkModel.title = title
    },
    // 导出txt
    exportTxt() {
      console.log('this.queryParam', this.queryParam)
      this.exportTxtLoading = true
      postAction('dasdsad', {
        exportType: 'txt',
        ...this.getQueryParams()
      }).then((res) => {
        console.log('导出txt结果', res)
        if (res.code === 1) {
          txtDown('导出txt', res.data.txtData)
        }
      }).finally(() => {
        this.exportTxtLoading = false
      })
    },
    handleEdit(title, rowData, disableSubmit) {
      this.$refs.modalForm.edit(rowData)
      this.$refs.modalForm.title = title
      this.$refs.modalForm.disableSubmit = disableSubmit
    }
  }
}
</script>

<style lang="scss" scoped>
.overflow2{
  word-break: break-all;
  text-overflow: ellipsis;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
</style>

